<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>配送关系日志(配送企业)</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>配送关系日志</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送关系日志</a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
             <div class="input">
            	<div class="textalign1">通用名：</div>
                <div class="boxinput">
                    <input class="textinput" type="text" id="drugName" id="drugName" placeholder="通用名" />
                </div>
            	<div class="textalign">药品编码：</div>
            	<div class="boxinput">
            		<input class="textinput" type="text" id="drugCode" name="drugCode" placeholder="药品编码" ></input>
            	</div>
            	<div class="textalign">生产企业：</div>
                <div class="boxinput">
                    <input class="textinput" type="text" id="compName" name="compName" placeholder="生产企业" />
                </div>
            </div>
            <div class="input" style="margin-top:-5px;">
            	
            	<div class="textalign1">医疗机构地区：</div>
            	<div class="boxinput">
            		<table style="width:100%;">
            			<tr>
            				<td style="width:33%;">
            					<select class="textinput"  disabled="disabled" id="area1" name="area1">
	                        		<option value="${area.areaId }">${area.areaName }</option>
	                        	</select>
            				</td>
            				<td style="width:33%;">
            					<select class="textinput"   id="area2" name="area2"></select>
            				</td>
            				<td style="width:33%;">
            					<select class="textinput"   id="area3" name="area3"></select>
            				</td>
            			</tr>
                     </table>
                  </div>
            	<div class="textalign">操作日期：</div>
            	<div class="boxinput">
            		<table style="width:100%;">
            			<tr>
            				<td style="width:45%;">
            					<input class="textinput" type="text" id="startTime" placeholder="yyyy-MM-dd" maxlength="10" 
                                onFocus="var endDate=$dp.$('endTime');WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}'})"  />
            				</td>
            				<td style="width:10%;text-align:center;">-</td>
            				<td style="width:45%;">
            					<input class="textinput" type="text" id="endTime"  placeholder="yyyy-MM-dd" maxlength="10" 
                                onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}'})"   />
            				</td>
            			</tr>
                     </table>
            	</div>
            	 <div class="textalign">
                 <button type="button" class="btn btn-success btn-sm" onclick="search();" id="selectc">查 询</button>
                </div>
            </div>
            
        </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
       
    </section>
	<%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script type="text/javascript">
    
	  //绑定回车
		$('#goodsCode,#drugCode,#drugName,#compName,#area1,#area2,#area3,#startTime,#endTime').bind('keydown', function(event) {
		    if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
		        $('#selectc').click();
		    }
		}); 
		
		$("#drugName").focus();//加载页面光标在第一个查询框上

    	function search(page) {
    		var goodsCode = $.trim($("#goodsCode").val());
    		var drugCode = $.trim($("#drugCode").val());
    		var drugName = $.trim($("#drugName").val());
    		var compName = $.trim($("#compName").val());
    		var areaCode = $.trim($("#area3").val());
    		var fatherCode = $.trim($("#area2").val());
    		var startTime = $("#startTime").val();
    		if (startTime != null && "" != startTime) {
    			startTime += " 00:00:00";
    		}
    		
    		var endTime = $("#endTime").val();
    		if (endTime != null && "" != endTime) {
    			endTime +=  " 23:59:59";
    		}
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{
    	        	"goodsCode":goodsCode,
    	        	"drugCode":drugCode,
    	        	"drugName":drugName,
    	        	"compName":compName,
    	        	"areaCode":areaCode,
    	        	"fatherCode":fatherCode,
    	        	"startTime":startTime, 
    	        	"endTime":endTime
    	        	},
    	        page : (page || 1)
    	    }).trigger("reloadGrid"); //重新载入  
    	}
    	
    	function drugByPSArea(goodsCode) {
    		window.location.href = "${ctx}/baseDel/toDrugByPSArea.html?goodsCode="+goodsCode;
    	}
    	
        $(function () {
            $("#gridlist").jqGrid({
                url: "${ctx}/baseDel/getBaseDelRelationLogByPs.html",
                mtype: "post",
                datatype: "json",
                //postData: {"projId" : "${projId}"},
                autowidth: true,
                shrinkToFit:true,
              //  height: 300,
                colNames: [
                    '状态',
					'配送区域',
					'采购限价',
					'药品编码',
					'通用名',
					'剂型',
					'规格',
					'转换系数',
					'单位', 
					'材质',
					'商品编码',
					'生产企业', 
					'操作时间',
					'操作人'
                ],
                colModel: [
                    { name: 'status',index:'status', width:80, align:"center", sortable:false},
                    { name: 'areaName', width: 120, align:"center", sortable: false},
                    { name:'proPriceLimit',index:'proPriceLimit', width:80,align:"right",  sortable:false},
                    { name: 'drugCode', width: 100, align:"center", sortable: false},
                    { name: 'drugName', width: 140, align:"left", sortable: false},
                    { name: 'formName', width: 80, align:"center", sortable: false},
                    { name: 'specName', width: 80, align:"left", sortable: false},
                    { name: 'factor', width: 80, align:"center", sortable: false},
                    { name: 'unit', width: 40, align:"center", sortable: false},
                    { name: 'materialName', width: 80, align:"center", sortable: false},
                    { name: 'goodsCode', width: 100, align:"center", sortable: false,hidden:true},
                    { name: 'compName', width: 180, align:"left", sortable: false},
                    
                    
                    { name: 'updDatetime',index:'updDatetime', width:140, align:"center", sortable:false},
                    { name: 'updUser',index:'updUser', width:200,align:"center",  sortable:false}
                ],
                rowNum: 20,
                rowList: [10, 20, 30],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: false, 
                viewrecords: true,
                caption: "我配送的药品",
                jsonReader: {
                    id: ""
                },
                gridComplete:function(){
                    //序号列宽度自适应（参数为jqgridID）
                    autoRNWidth("gridlist");
                    //数据只有一条时默认选中（参数为jqgridID）
                    selectByOneData("gridlist");
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
			$("#gridlist").jqGrid("setGridHeight", create());

            $("#area2").HNSelect({
            	parent_selector: "#area1",  url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID",defaultText: "<option value=''>请选择</option>",
                func: function () {
                    $("#area3").HNSelect({
                        parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''>请选择</option>",
                        		
                    });
                }
            });
        });
    </script>
</body>
</html>